package com.ihr360.payroll.service.eventhandler;

import com.ihr360.event.annonation.RestEventListener;
import com.ihr360.payroll.model.dto.attendance.plan.AttendancePlan;
import com.ihr360.payroll.service.attendanceplan.AttendancePlanService;
import com.ihr360.validation.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author tomtao
 */
@Component
public class AttendancePlanRestEventListener implements RestEventListener<AttendancePlan, Long> {

    @Autowired
    private AttendancePlanService service;

    @Override
    public void beforeDeleteOne(Long id) {
        if (service.isReferenced(id, false)) {
            ValidationUtils.reject("", "被引用不能删除！");
        }
    }

}
